package phase01.module2.code.question2;

import phase01.module2.code.question2.exceptions.InvalidLocationException;

public class Coordinate {
    private int x;
    private int y;
    public Coordinate() {}
    public Coordinate(int x, int y) throws InvalidLocationException {
        setX(x);
        setY(y);
    }

    public int getX() {
        return x;
    }

    public void setX(int x) throws InvalidLocationException {
        if (x < 0) {
            throw new InvalidLocationException();
        }
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) throws InvalidLocationException {
        if (y < 0) {
            throw new InvalidLocationException();
        }
        this.y = y;
    }
}
